<template>
  <div class="home">
    <!-- 首页搜索框 -->
    <van-search
      v-model="searchVal"
      shape="round"
      placeholder="请输入搜索关键词"
      disabled
      @click="$router.push('/home/searchPopup')"
    />
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="blue">
      <van-swipe-item v-for="item in banner" :key="item.id">
        <img :src="item.image_url" width="100%" alt="" />
      </van-swipe-item>
    </van-swipe>
    <transition name="slide">
      <router-view></router-view>
    </transition>
  </div>
</template>

<script>
// @ is an alias to /src
// import HelloWorld from '@/components/HelloWorld.vue'
import { GetHomeData } from "@/request/api";
export default {
  data() {
    return {
      searchVal: "",
      banner: ""
    };
  },
  created() {
    GetHomeData()
      .then(res => {
        this.banner = res.data.banner;
      })
      .catch(err => {
        console.log(err);
      });
  },
  name: "Home",
  components: {}
};
</script>
<style lang="less">
.slide-enter , .slide-leave-to{
  /*进场初始效果*/
  right: -100%;
}
.slide-enter-active , .slide-leave-active {
  transition: all 0.2s;
}
.slide-enter-to, .slide-leave {
  /*进场最终效果*/
  right: 0;
}
</style>
